home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F36228_strSplittoWords.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  1.8 KB  |  56 lines

  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:saxon="http://icl.com/saxon"
  4. xmlns:str-split2words-func="f:str-split2words-func"
  5. exclude-result-prefixes="xsl saxon str-split2words-func"
  6. >
  7.  
  8.    <xsl:import href="str-foldl.xsl"/>
  9.  
  10.    <!-- to be applied on words.xml -->
  11.  
  12.    <str-split2words-func:str-split2words-func/>
  13.  
  14.    <xsl:param name="pDelimiters" select="',  '"/>
  15.  
  16.    <xsl:output indent="yes" omit-xml-declaration="yes"/>
  17.    
  18.     <xsl:template match="/">
  19.       <xsl:call-template name="str-split-to-words">
  20.         <xsl:with-param name="pStr" select="/*/*"/>
  21.       </xsl:call-template>
  22.     </xsl:template>
  23.  
  24.     <xsl:template name="str-split-to-words">
  25.       <xsl:param name="pStr" select="dummy"/>
  26.       
  27.       <xsl:variable name="vsplit2wordsFun"
  28.                     select="document('')/*/str-split2words-func:*[1]"/>
  29.  
  30.       <xsl:call-template name="str-foldl">
  31.         <xsl:with-param name="pFunc" select="$vsplit2wordsFun"/>
  32.         <xsl:with-param name="pStr" select="$pStr"/>
  33.         <xsl:with-param name="pA0" select="/.."/>
  34.       </xsl:call-template>
  35.  
  36.     </xsl:template>
  37.  
  38.     <xsl:template match="str-split2words-func:*">
  39.       <xsl:param name="arg1" select="/.."/>
  40.       <xsl:param name="arg2"/>
  41.          
  42.       <xsl:choose>
  43.         <xsl:when test="contains($pDelimiters, $arg2)">
  44.             <xsl:copy-of select="saxon:node-set($arg1)/*"/>
  45.             <xsl:if test="string($arg1/*[last()])">
  46.               <word/>
  47.             </xsl:if>
  48.         </xsl:when>
  49.         <xsl:otherwise>
  50.           <xsl:copy-of select="saxon:node-set($arg1)/*[position() < last()]"/>
  51.           <word><xsl:value-of select="concat($arg1/*[last()], $arg2)"/></word>
  52.         </xsl:otherwise>
  53.       </xsl:choose>
  54.     </xsl:template>
  55.  
  56. </xsl:stylesheet>